import { Router } from "vue-router";
import { useTitle } from '@vueuse/core'
// import { useRouteStore } from "@/store/route/route";
import { createPermissionGuard } from "./permission";

export function createRouteGuard(router: Router) {
    router.beforeEach(async (to, from, next) => {
        console.log("路由加载……——beforeEach");

        // 显示加载条
        window.$loadingBar?.start();
        // const route = useRouteStore()
        // route.initDynamicRoute(router)
        // 页面跳转权限处理
        // debugger
        await createPermissionGuard(to, from, next, router);
    });
    /* eslint-disable */
    router.afterEach((to: any) => {
        useTitle(to.meta.title)
        window.$loadingBar?.finish();
    })
}